import Layer from '@/components/Layer'

export default {
	install(Vue,options){
    /*let vueLoading = Vue.extend({
      render(h) {
        let props = {
          show: this.show
        }
        return h('Loading', {props})
      },
      data() {
        return {
          show: true
        }
      }
    })*/
    let vueLayer = Vue.extend(Layer),
    newLayer = new vueLayer(),
    vm = newLayer.$mount(),
    el = vm.$el
    document.body.appendChild(el)

    let open=(opts)=>{
      vm.skin=''
      vm.anim='scale'
      vm.title='提示信息'
      vm.isShow=true
      Object.assign(vm,opts)
      clearTimeout(vm.timer)
    }
    window.layer={
      open:open,
      close:()=>{
        vm.isShow=false
      }
    }
    window.alert =(txt)=>{
      vm.skin='msg'
      vm.anim='up'
      vm.content=txt
      vm.isShow=false
      clearTimeout(vm.timer)
      vm.$nextTick(()=>{
        vm.isShow=true
        vm.timer=setTimeout(()=>{
          vm.isShow=false
        },2000)
      })
    }
    Vue.prototype.$loading={
      show(options) {
        vm.skin='loading'
        vm.isShow=true
      },
      hide() {
        vm.isShow=false
      }
    }
	}
}